<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<h5 matDialogTitle>
  Role mappings
</h5>
<mat-dialog-content>
  <form #userRoleForm="ngForm" fxLayout="column">
    <div fxLayout="column" fxFlex>
      <h5 style="color: grey; margin: 5px 0 5px 0;">Users</h5>
      <div>
        <gv-expression-language name="user"
                                placeholder="Use attributeName=attributeValue or EL syntax."
                                ngDefaultControl
                                gvControl
                                ngModel
                                required
                                inner-hint
                                rows="1"></gv-expression-language>
      </div>
    </div>
    <h5 style="color: grey; margin:  5px 0 15px 0;">Roles</h5>
    <mat-form-field>
      <mat-select placeholder="Roles" name="roles" ngModel [multiple]="!data.organizationContext" required>
        <mat-option *ngFor="let role of data.roles" [value]="role.id" [disabled]="role.name.endsWith('_PRIMARY_OWNER') && role.system === true">{{ role.name }}</mat-option>
      </mat-select>
    </mat-form-field>
  </form>
</mat-dialog-content>
<mat-dialog-actions>
  <button type="button" mat-raised-button color="primary" (click)="dialogRef.close(userRoleForm.value)" color="primary" [disabled]="userRoleForm.invalid || formInvalid">Save</button>
  <button type="button" mat-button (click)="dialogRef.close()" class="dialog-cancel" style="margin-left: 20px;">Cancel</button>
</mat-dialog-actions>
